home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94b.txt
/
000092_icon-group-sender _Fri Nov 4 11:19:05 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1995-02-09
|
2KB
Received: by cheltenham.cs.arizona.edu; Fri, 4 Nov 1994 12:45:55 MST
Message-Id: <9411041819.AA11551@orpheus.gemini.edu>
From: swampler@noao.edu
Date: Fri, 4 Nov 1994 11:19:05 GMT+447
X-Mailer: Mail User's Shell (7.2.3 5/22/91)
To: icon-group@cs.arizona.edu
Subject: A debugging hint...
Content-Length: 1478
Errors-To: icon-group-errors@cs.arizona.edu
This is a trick I use when debugging Icon code. Maybe someone else
will find it useful...
When trying to track down a bug in an Icon program, &trace does
a nice job of showing the procedure calls and returns, including
the line numbers. Unfortunately, it doesn't help in sections of
code where there are long stretches without any procedure calls.
A common method to 'trace' in those code stretches is to embed
calls to 'write()', but then you have to do something to each
call to disable them for runs without tracing, and put something
into the argument list to each write to identify the line (&line
is nice for that, incidently, etc.)
Let &trace work for you. Create a procedure:
procedure Trace(s)
return
end
and embed the calls to it where you would have put the write()s before:
Trace(i)
...
Trace("at start of loop")
etc.
Now just run the program with &trace turned on. Presto, you see
a nice 'trace' showing the line numbers of the calls to Trace and
the value of the argument. Turn off &trace, and the debug output
isn't shown.
If you want to see multiple values at each trace point, change
the procedure to:
procedure Trace(s[])
return
end
and now you can call it as:
Trace("size of table is", *symbol_table)
I hope someone finds this useful.
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
--
The Gods that were smiling when you were born are laughing now.
-- found in a fortune cookie